package com.probox.common.entity.service.recharge.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.probox.common.core.utils.StringUtils;
import com.probox.common.entity.domain.recharge.RechargeRecordRights;
import com.probox.common.entity.mapper.recharge.RechargeRecordRightsMapper;
import com.probox.common.entity.service.recharge.IRechargeRecordRightsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * 充值对应的权益Service业务层处理
 *
 * @author usoft
 * @date 2022-11-02
 */
@Service
@Transactional
public class RechargeRecordRightsServiceImpl extends ServiceImpl<RechargeRecordRightsMapper, RechargeRecordRights> implements IRechargeRecordRightsService {
    @Autowired
    private RechargeRecordRightsMapper rechargeRecordRightsMapper;


    /**
     * 查询充值对应的权益
     *
     * @param detailId 充值对应的权益ID
     * @return 充值对应的权益
     */
    @Override
    public RechargeRecordRights selectRechargeRecordRightsById(Long detailId) {
        return this.getById(detailId);
    }

    /**
     * 查询充值对应的权益列表
     *
     * @param rechargeRecordRights 充值对应的权益
     * @return 充值对应的权益
     */
    @Override
    public List<RechargeRecordRights> queryList(RechargeRecordRights rechargeRecordRights) {
        QueryWrapper<RechargeRecordRights> queryWrapper = Wrappers.query();
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getDetailId())) && rechargeRecordRights.getDetailId() != null) {
            queryWrapper.eq("detail_id", rechargeRecordRights.getDetailId());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getRecordId())) && rechargeRecordRights.getRecordId() != null) {
            queryWrapper.eq("record_id", rechargeRecordRights.getRecordId());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getRechargeId())) && rechargeRecordRights.getRechargeId() != null) {
            queryWrapper.eq("recharge_id", rechargeRecordRights.getRechargeId());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getRightId())) && rechargeRecordRights.getRightId() != null) {
            queryWrapper.eq("right_id", rechargeRecordRights.getRightId());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getRightType())) && rechargeRecordRights.getRightType() != null) {
            queryWrapper.eq("right_type", rechargeRecordRights.getRightType());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getRightObjectId())) && rechargeRecordRights.getRightObjectId() != null) {
            queryWrapper.eq("right_object_id", rechargeRecordRights.getRightObjectId());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getRightSort())) && rechargeRecordRights.getRightSort() != null) {
            queryWrapper.eq("right_sort", rechargeRecordRights.getRightSort());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getRightAmount())) && rechargeRecordRights.getRightAmount() != null) {
            queryWrapper.eq("right_amount", rechargeRecordRights.getRightAmount());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getDataStatus())) && rechargeRecordRights.getDataStatus() != null) {
            queryWrapper.eq("data_status", rechargeRecordRights.getDataStatus());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getCreateUser())) && rechargeRecordRights.getCreateUser() != null) {
            queryWrapper.eq("create_user", rechargeRecordRights.getCreateUser());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getCreateName())) && rechargeRecordRights.getCreateName() != null) {
            queryWrapper.eq("create_name", rechargeRecordRights.getCreateName());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getUpdateUser())) && rechargeRecordRights.getUpdateUser() != null) {
            queryWrapper.eq("update_user", rechargeRecordRights.getUpdateUser());
        }
        if (StringUtils.isNotEmpty(String.valueOf(rechargeRecordRights.getUpdateName())) && rechargeRecordRights.getUpdateName() != null) {
            queryWrapper.eq("update_name", rechargeRecordRights.getUpdateName());
        }
        return rechargeRecordRightsMapper.selectList(queryWrapper);
    }

    /**
     * 新增充值对应的权益
     *
     * @param rechargeRecordRights 充值对应的权益
     * @return 结果
     */
    @Override
    public boolean insertRechargeRecordRights(RechargeRecordRights rechargeRecordRights) {

        return this.save(rechargeRecordRights);

    }

    /**
     * 修改充值对应的权益
     *
     * @param rechargeRecordRights 充值对应的权益
     * @return 结果
     */
    @Override
    public boolean updateRechargeRecordRights(RechargeRecordRights rechargeRecordRights) {

        return this.updateById(rechargeRecordRights);
    }

    /**
     * 批量删除充值对应的权益
     *
     * @param detailIds 需要删除的充值对应的权益ID
     * @return 结果
     */
    @Override
    public boolean deleteRechargeRecordRightsByIds(Long[] detailIds) {
        return this.removeByIds(Arrays.asList(detailIds));
    }


}
